comment-region)comment-region isn't actually part of CC Mode - it
is given a CC Mode binding for convenience.comment-dwim or
indent-for-comment 1)comment-column
(see Options
for Comments) and the variables below. Finally, position
the point after the comment starter. C-u M-; kills
any comment on the current line, together with any whitespace
before it. This is a standard Emacs command, but CC Mode
enhances it a bit with two variables:
This style variable allows you to vary the column that M-; puts the comment at, depending on what sort of code is on the line, and possibly the indentation of any similar comment on the preceding line. It is an association list that maps different types of lines to actions describing how they should be handled. If a certain line type isn't present on the list then the line is indented to the column specified by
comment-column.See the documentation string for a full description of this variable (use C-h v c-indent-comment-alist).
Normally, when this style variable is
nil, M-; will indent comment-only lines according toc-indent-comment-alist, just as it does with lines where other code precede the comments. However, if you want it to act just like <TAB> for comment-only lines you can get that by settingc-indent-comments-syntactically-pto non-nil.If
c-indent-comments-syntactically-pis non-nilthenc-indent-comment-alistwon't be consulted at all for comment-only lines.